﻿using FluentValidation;
using FluentValidation.Results;

namespace Quickly.Identity.API;

public class HostFrontendOption
{
    public string? PhysicalPath { get; set; }
    public string? RequestPath { get; set; }
    public string[]? DefaultFiles { get; set; } = new string[] { "index.html" };
}

public static class HostFrontendOptionExtensions
{
    public static ValidationResult Validate(this HostFrontendOption option)
    {
        var validator = new HostFrontendOptionValidator();
        var result = validator.Validate(option);
        return result;
    }
}

public class HostFrontendOptionValidator : AbstractValidator<HostFrontendOption>
{
    public HostFrontendOptionValidator()
    {
        RuleFor(x => x).NotNull().WithMessage("配置为空");
        RuleFor(x => x.PhysicalPath).NotNull().NotEmpty().WithMessage($"物理路径为空：{nameof(HostFrontendOption.PhysicalPath)}");
        //RuleFor(x => x.RequestPath).NotNull().NotEmpty().WithMessage($"访问路径为空：{nameof(HostFrontendOption.RequestPath)}");
    }
}
